package testcase;

import static org.junit.Assert.*;

import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;

import org.junit.Test;

import dataStructure.LinkedList;
import entity.FileAsso;

public class TestLinkedList {

	@Test
	public void testAddNode() throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException, ParseException {
		LinkedList<FileAsso> fAssoList= new LinkedList<FileAsso>();
		FileAsso fileAsso = new FileAsso("a", "a.txt");
		
		fAssoList.addContent(fileAsso);//After converting to ListNode, it will call list.addNode();
		
		String result = fAssoList.getLastNodeContent().getContentStr();
		
		assertEquals("a a.txt", result);
	}

	@Test
	public void testSearchNodes() throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException, NullPointerException, NoSuchMethodException, InvocationTargetException, ParseException {
		LinkedList<FileAsso> fAssoList= new LinkedList<FileAsso>();
		FileAsso fileAsso = new FileAsso("a", "a.txt");
		fAssoList.addContent(fileAsso);//After converting to ListNode, it will call list.addNode();

		fileAsso = new FileAsso("b", "b.txt");
		fAssoList.addContent(fileAsso);
		fileAsso = new FileAsso("c", "c.txt");
		fAssoList.addContent(fileAsso);
		
		String result = fAssoList.searchContent("dataIdentifer", "b").getContentStr();
		assertEquals("b b.txt", result);
	}

	@Test
	public void testRemoveNode() throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException, NullPointerException, NoSuchMethodException, InvocationTargetException {
		LinkedList<FileAsso> fAssoList= new LinkedList<FileAsso>();
		FileAsso fileAsso = new FileAsso("a", "a.txt");
		fAssoList.addContent(fileAsso);//After converting to ListNode, it will call list.addNode();

		fileAsso = new FileAsso("b", "b.txt");
		fAssoList.addContent(fileAsso);
		fileAsso = new FileAsso("c", "c.txt");
		fAssoList.addContent(fileAsso);
		
		fAssoList.removeNode(fileAsso);
		FileAsso result=fAssoList.searchContent("dataIdentifer", "c");
		assertEquals(null, result);
	}

	@Test
	public void testInsertNode() {
		
	}

	@Test
	public void testSearchNodeContent() {
		
	}

}
